package com.fenqing.leetcode.code.t2300_2400;

import com.fenqing.annotations.Execute;
import com.fenqing.core.Topic;

import java.util.HashSet;
import java.util.Set;

public class Topic2351 extends Topic {

    @Execute
    public char repeatedCharacter(String s) {
        Set<Character> set = new HashSet<>();
        char[] chars = s.toCharArray();
        for (int i = 0; i < chars.length; i++) {
            char aChar = chars[i];
            if (set.contains(aChar)) {
                return aChar;
            } else {
                set.add(aChar);
            }
        }
        return 'a';
    }

    public static void main(String[] args) {
        Topic2351 topic2351 = new Topic2351();
        char run = topic2351.run("abcdd");
        System.out.println(run);
    }

}
